def determine_member_level(consume_amount, points):
    # 从高到低判断会员等级，避免优先级冲突
    if consume_amount >= 1000 and points >= 10000:
        return "钻石会员"
    elif 500 <= consume_amount < 1000 and 5000 <= points < 10000:
        return "白金会员"
    elif 200 <= consume_amount < 500 and 2000 <= points < 5000:
        return "黄金会员"
    elif 100 <= consume_amount < 200 and 1000 <= points < 2000:
        return "白银会员"
    elif 500 <= points < 1000:
        return "青铜会员"
    elif points < 500:
        return "普通会员"
    else:
        return "等级未知"

def get_valid_number(input_prompt):
    """获取用户输入的有效数字（处理非数字输入错误）"""
    while True:
        user_input = input(input_prompt)
        try:
            # 金额支持小数，积分后续转换为整数
            number = float(user_input)
            if number < 0:
                print("❌ 输入不能为负数，请重新输入！")
                continue
            return number
        except ValueError:
            print("❌ 输入无效，请输入正确的数字！")

def ask_continue():
    """询问用户是否继续查询（处理无效输入）"""
    while True:
        choice = input("\n是否继续查询会员等级？（y/n）：").strip().lower()
        if choice in ["y", "n"]:
            return choice == "y"
        else:
            print("❌ 输入无效，请输入 'y'（继续）或 'n'（退出）！")

if __name__ == "__main__":
    print("=" * 40)
    print("🎯 会员等级查询系统 V2.0")
    print("=" * 40)
    
    while True:
        # 1. 获取用户输入（带验证）
        print("\n请输入以下信息：")
        consume = get_valid_number("📥 累计消费金额（元）：")
        point = get_valid_number("📥 当前积分：")
        
        # 2. 积分转换为整数（积分通常为整数，避免小数情况）
        point = int(point)
        
        # 3. 计算会员等级
        member_level = determine_member_level(consume, point)
        
        # 4. 格式化输出结果
        print("\n" + "-" * 40)
        print(f"📊 您的消费金额：{consume:.2f}元")
        print(f"📊 您的当前积分：{point}分")
        print(f"🏆 您的会员等级：{member_level}")
        print("-" * 40)
        
        # 5. 询问是否继续查询
        if not ask_continue():
            print("\n👋 感谢使用会员等级查询系统，再见！")
            print("=" * 40)
            break